<?php
class XObject{
	/** 
	 * @return mixed
	 */		
	public function __get($key){
		if(method_exists($this, $key)){
			return $this->$key();
		}
		$method = 'get'.x_name_to_java($key);
		if(method_exists($this, $method)){
			return $this->$method();
		}
		if(method_exists($this, 'get')){
			return $this->get($key);
		}
		if(isset($this->$key)){
			return $this->$key;
		}
		return null;
	}
	
	/** 
	 * @return XObject
	 */		
	public function __set($key, $value){
		$method = 'set'.x_name_to_java($key);
		if(method_exists($this, $method)){
			$this->$method($value);
			return $this;
		}
		if(method_exists($this, 'set')){
			$this->set($key, $value);
			return $this;
		}
		$this->$key = $value;
		return $this;
	}
	
	public function __call($method, $args){
		return call_user_func_array(array($this, $method), $args);
  	}
	
	/** 
	 * @return array
	 */	
	public function asArray(){
		return get_object_vars($this);
	}
}
?>